//    Openbravo POS is a point of sales application designed for touch screens.
//    Copyright (C) 2007-2009 Openbravo, S.L.
//    http://www.openbravo.com/product/pos
//
//    This file is part of Openbravo POS.
//
//    Openbravo POS is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    Openbravo POS is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with Openbravo POS.  If not, see <http://www.gnu.org/licenses/>.

package com.openbravo.pos.bean;


import com.openbravo.bean.Product;
import java.awt.image.BufferedImage;
import com.openbravo.data.loader.ImageUtils;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.HashMap;

/**
 *
 * @author adrianromero
 *
 */
public class ProductExt extends Product implements Externalizable{

    protected byte[] m_Image;
    protected boolean catalog;
    protected int catorder;
    protected double stockCost;
    protected double stockVolume;


    @Override
    public void writeExternal(ObjectOutput out) throws IOException {
        out.writeObject(m_ID);
        out.writeObject(m_sRef);
        out.writeObject(m_sCode);
        out.writeObject(m_sName);
        out.writeBoolean(m_bCom);
        out.writeBoolean(m_bScale);
        out.writeObject(categoryid);
        out.writeObject(taxcategoryid);
        out.writeObject(attributesetid);
        out.writeDouble(m_dPriceBuy);
        out.writeDouble(m_dPriceSell);
        out.writeDouble(m_dCustomerPrice);
        out.write(m_Image);
        out.writeObject(attributes);
        out.writeObject(m_origin);
        out.writeObject(m_quantity);
        out.writeObject(m_unit);
        out.writeObject(m_sManufacturer);
        out.writeObject(m_sSimilarCode);
        out.writeObject(m_iDurability);
        out.writeObject(catalog);
        out.writeObject(catorder);
        out.writeObject(stockCost);
        out.writeObject(stockVolume);
        out.writeDouble(m_dWholesalePrice);

        
    }

    @Override
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
        m_ID = (String) in.readObject();
        m_sRef = (String) in.readObject();
        m_sCode = (String) in.readObject();
        m_sName = (String) in.readObject();
        m_bCom = in.readBoolean();
        m_bScale = in.readBoolean();
        categoryid = (String) in.readObject();
        taxcategoryid = (String) in.readObject();
        attributesetid = (String) in.readObject();
        m_dPriceBuy = in.readDouble();
        m_dPriceSell = in.readDouble();
        m_dCustomerPrice=in.readDouble();
        byte[] b=new byte[]{};
        in.read(b);
        m_Image = b;
        attributes = (HashMap) in.readObject();
        m_origin=(String)in.readObject();
        m_quantity=in.readDouble();
        m_unit=(String)in.readObject();
        m_sManufacturer=(String)in.readObject();
        m_sSimilarCode=(String)in.readObject();
        m_iDurability=(Integer)in.readObject();
        catalog=in.readBoolean();
        catorder=(Integer)in.readObject();
        stockCost=in.readDouble();
        stockVolume=in.readDouble();
        m_dWholesalePrice=in.readDouble();
       
    }

    public byte[] getImage() {
        return m_Image;
    }

    public void setImage(byte[] img) {
        m_Image = img;
    }

    public byte[] getM_Image() {
        return m_Image;
    }

    public void setM_Image(byte[] m_Image) {
        this.m_Image = m_Image;
    }

    public boolean isCatalog() {
        return catalog;
    }

    public void setCatalog(boolean catalog) {
        this.catalog = catalog;
    }

    public int getCatorder() {
        return catorder;
    }

    public void setCatorder(int catorder) {
        this.catorder = catorder;
    }

    public double getStockCost() {
        return stockCost;
    }

    public void setStockCost(double stockCost) {
        this.stockCost = stockCost;
    }

    public double getStockVolume() {
        return stockVolume;
    }

    public void setStockVolume(double stockVolume) {
        this.stockVolume = stockVolume;
    }
}
